<!DOCTYPE html>
<html>
<head>
<title>项目详情</title>
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="../layui/css/layui.css" media="all">
<link rel="stylesheet" href="../statics/css/msgdetail.css">
<script src="../statics/js/jquery-1.12.4.js"></script>
<script src="../statics/js/area.js"></script>
<script type="text/javascript">
function realod(){
  var {search,href} = window.location;
  href = href.replace(/&?t_reload=(\d+)/g,'')
  window.location.href = href+(search?'&':'?')+"t_reload="+new Date().getTime()
}
</script>
</head>
<body>
	<table class="layui-table detail_table" id="msg_detail">
		<thead>
			<tr>
				<td colspan="2">订单详情</td>
			</tr>
		</thead>
		<tbody>
			<tr>
				<th>客户需求产品</th>
				<td id="customer_type_product" name="customer_type_product"></td>
			</tr>
			<tr>
				<th>姓名</th>
				<td id="provider_name" name="provider_name"></td>
			</tr>
			<tr>
				<th>提供者手机号</th>
				<td id="provider_phone_number"></td>
			</tr>
			<tr>
				<th>订单号</th>
				<td id="orderNo"></td>
			</tr>
			<tr>
				<th>项目名称</th>
				<td id="project_name" name="project_name"></td>
			</tr>
			<tr>
				<th>项目启动时间</th>
				<td id="project_start_time"></td>
			</tr>
			<tr>
				<th>项目预估规模</th>
				<td id="scale"></td>
			</tr>
			<tr>
				<th>项目客户类型</th>
				<td id="customer_type"></td>
			</tr>
			<tr>
				<th>项目所在地点</th>
				<td id="area"></td>
			</tr>
			<tr>
				<th>项目描述</th>
				<td id="project_description"></td>
			</tr>
			<tr>
				<th>项目真实性</th>
				<td id="truth_type"></td>
			</tr>
			<tr>
				<th>项目真实性内容</th>
				<td id="file_url"></td>
			</tr>
			<tr>
				<th>我需要一次面对面沟通</th>
				<td id="communic"></td>
			</tr>
			<!-- <tr>
				<th>我关心项目进展</th>
				<td id="project_progress"></td>
			</tr> -->
			<tr>
				<th>我想成为（推荐）渠道商</th>
				<td id="channel"></td>
			</tr>
			<tr>
				<th>相似项目名称</th>
				<td id="like_name"></td>
			</tr>
			<tr>
				<th>相似度</th>
				<td id="like_value"></td>
			</tr>
			<tr>
				<th>红包金额(元)</th>
				<td id="money"></td>
			</tr>
			<tr>
				<th>创建时间</th>
				<td id="createTime"></td>
			</tr>
			<tr>
				<th>提交用户</th>
				<td id="nickname"></td>
			</tr>
			<tr>
				<th>转发用户</th>
				<td id="zf_name"></td>
			</tr>
		</tbody>
	</table>
	<div style="margin: 2%;width: 96%;">
		<div id="btn">
			 <!-- <button class="layui-btn layui-btn-normal layui-btn-small a1" lay-event="f_event" style="min-width: 30%;" onclick="f_event('+id+');">初审</button>
			<button data-method="reject_event" class="layui-btn layui-btn-normal layui-btn-small a1" style="min-width: 30%;">拒绝</button>
			<button class="layui-btn layui-btn-normal layui-btn-small  a1" style="min-width: 30%;">复审</button> -->  
		</div>
	</div>
	<div id="reject" style="padding:2%;display:none;">
		<select id="rejectSelect" onchange="add_rejectreason()" style="width:100%;">
			<option lay-value="-1">请选择拒绝理由</option>
			<option lay-value="0">尊敬的客户，经核实，您提供的项目信息不存在；</option>
			<option lay-value="1">尊敬的客户，经核实，您提供的项目信息已存在；</option>
			<option lay-value="2">尊敬的客户，经核实，您提供的项目信息有误；</option>
        </select>
		<textarea id="reject_reason" name="reject_reason" required lay-verify="required" placeholder="请输入拒绝理由,提交后会微信推送服务消息给用户。" class="layui-textarea"></textarea>
		<button class="layui-btn layui-btn-normal layui-btn-small a1" style="text-align:center;margin:0 auto;width:-webkit-fill-available;" onclick="due_reject()">确定</button>    
	</div>
</body>
<!-- <script type="text/javascript" src="../layui/layui.js"></script> -->
<script type="text/javascript" src="../statics/js/layer/layer.js"></script>
<script>
	//页面传参
	function getUrlParam(name) {
		var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
		var r = window.location.search.substr(1).match(reg);
		if (r != null) return unescape(r[2]);
		return null;
	};
	
var id ="";
		// var channel_user_id=sessionStorage.getItem("channel_user_id");  
		//监听提交
		$(document).ready(function(data){
		
		    id=getUrlParam("id");
		    
			$.ajax({
				type : "POST",
				url : '../rest/find_msgdetail',
				//async:true,
				data : {
					"id":id
				},
				dataType : "json",
				success : function(data) {
					
					if (data.status == false) {
						//layer.alert(data.msg, { title: '信息',icon: 5});
						layer.msg("出错，请重新进入！", {
							icon : 5,
							time : 3000
						});
						//alert("失败");
					} else {
					var id = data.msgEnter.id;
					var project_name = data.msgEnter.project_name;
					var orderNo = data.msgEnter.orderNo;
					var provider_name = data.msgEnter.provider_name;
					var provider_phone_number = data.msgEnter.provider_phone_number;
					var project_start_time = data.msgEnter.project_start_time;
					var scale = data.msgEnter.scale;
					var provid = provinceAndCityArray[data.msgEnter.provid].name;
					
					var cityid = provinceAndCityArray[data.msgEnter.provid].cities[data.msgEnter.cityid];
					var area = provid+cityid;
					var customer_type = data.msgEnter.customer_type;
					var project_description = data.msgEnter.project_description;
					var truth_type = data.msgEnter.truth_type;
					var file_url = data.msgEnter.file_url;
					var communic = data.msgEnter.communic;
					var project_progress = data.msgEnter.project_progress;
					var money = data.msgEnter.money;
					var createTime = new Date(data.msgEnter.createTime).toLocaleString();
					var review = data.msgEnter.review;
					var trial = data.msgEnter.trial;
					var customer_type_product = data.msgEnter.customer_type_product;
					var channel = data.msgEnter.channel;
					var like_name = data.msgEnter.like_name;
					var like_value = data.msgEnter.like_value;
					if(like_name == undefined){
						$("#like_name").html("<span></span>");
					}else{
						$("#like_name").html("<span>"+like_name+"</span>");
					}
					if(like_value == undefined){
						$("#like_value").html("<span></span>");
					}else{
						$("#like_value").html("<span>"+like_value+"</span>");
					}
					var nickname = data.msgEnter.nickname;
					var zf_name = data.msgEnter.zf_name;
					$("#nickname").html("<span>"+nickname+"</span>");
					if(zf_name == undefined){
						$("#zf_name").html("<span></span>");
					}else{
						$("#zf_name").html("<span>"+zf_name+"</span>");
					}
					
					$("#orderNo").html("<span>"+orderNo+"</span>");
					$("#provider_name").html("<span>"+provider_name+"</span>");
					$("#project_name").html("<span>"+project_name+"</span>");
					$("#provider_phone_number").html("<span>"+provider_phone_number+"</span>");
					$("#scale").html("<span>"+scale+"</span>");
					$("#area").html("<span>"+area+"</span>");
					$("#customer_type").html("<span>"+customer_type+"</span>");
					$("#project_description").html("<span>"+project_description+"</span>");
					if(truth_type =="0" ){
						 $("#truth_type").html("<span>招标信息</span>");
					}else if(truth_type =="1"){
						$("#truth_type").html("<span>该项目立项信息</span>");
					}else if(truth_type =="2"){
					$("#truth_type").html("<span>甲方直接负责人联系电话</span>");
					}else if(truth_type =="3"){
					$("#truth_type").html("<span>其他证明方法</span>");
					}
					 if(truth_type =="0" || truth_type =="1" || truth_type =="3"){
					         	 if(file_url !=""  && file_url !="null" && file_url !="undefined"){
								 	$("#file_url").html("<a  href="+file_url+" >点击查看</a>");
								 }
								// else{
					         	//	return "无附件"
					      		//}
							}else if(truth_type =="2"){
								$("#file_url").html("<span>"+file_url+"</span>");
							}
					if(communic=="尽快与我取得联系"){
					      	 $("#communic").html("<span>√</span>");
					      }
					      //else {
					      //	   return ""
					      //}    
					$("#project_start_time").html("<span>"+project_start_time+"</span>");
					$("#project_progress").html("<span>"+project_progress+"</span>");
					$("#money").html("<input type='text' name='money' value='"+money+"' onblur=out('"+id+"');>");
					$("#createTime").html("<span>"+createTime+"</span>");
					$("#customer_type_product").html("<span>"+customer_type_product+"</span>");
					if(channel=="我想成为（推荐）渠道商"){
					      	 $("#channel").html("<span>√</span>");
					      }
					if(trial=='1'){ 
			          if(review=='1'){	 
			          	  $("#btn").html('<button class="layui-btn layui-btn-normal layui-btn-small a1" style="min-width: 150px;">审核通过</button> ')
			          }
			          else  if(review=='-1'){
				            $("#btn").html('<button class="layui-btn layui-btn-disabled" >已拒绝</button>')
				      }
			          else{ 
			           	  //$("#btn").html('<button class="layui-btn layui-btn-normal layui-btn-disabled a1" disabled="disabled" style="min-width: 150px;">初审通过</button><button class="layui-btn layui-btn-normal layui-btn-small a1" onclick="ff_event('+id+');" style=" min-width: 150px;float: right;">复审</button>')
			                $("#btn").html('<button class="layui-btn layui-btn-normal layui-btn-disabled a1" disabled="disabled" style="min-width: 150px;">初审通过</button>')
			          }
			         }else if(trial=='0'){
			              if(review=='-1'){
				            $("#btn").html('<button class="layui-btn layui-btn-disabled" >已拒绝</button>')
				          }else{
				           $("#btn").html('<button class="layui-btn layui-btn-normal layui-btn-small a1" lay-event="f_event" style="min-width: 30%;" onclick="f_event('+id+');">初审</button>'+'<button onclick="reject_event('+id+');" class="layui-btn layui-btn-normal layui-btn-small a1" style="min-width: 30%;">拒绝</button>')   
				          }
				      }
					}
				}
			});

			return false;
		});
		
</script>
<script type="text/javascript">
	function out(id){
		var money = $("input[name='money']").val();
		console.info("money"+money);
		console.info("id"+id);
			$.ajax({
				type : "POST",
				url : '../rest/msgUpdate2',
                   data : {
						id:id,
						money:money
				},
				dataType : "json",
				//contentType: "application/json;charset=UTF-8"
				success : function(data) {
				  // alert("修改红包金额为："+data.money);
				}
			})
		};
/*  function img_event(img_url){
      window.open(img_url);
   } */
</script>
<script type="text/javascript">
function f_event(id){
//alert(id);
	if(confirm("您确定通过 ["+provider_name.innerText+"] 提供的项目吗？")){
		 $.ajax({
             type : "POST",
             url : '../rest/comfire_trial',
             //async:true,
             data : {
                 id:id
             },
             dataType : "json",
             success : function(data) {
                 if(data.status==false){
                	 alert(data.msg, {icon: 5,time:1500});
				}else{
			         alert(data.msg, {icon: 1,time:1500});
			         //执行重载
                     //location.reload([false]) 
						realod();
			     }
                 }
          });
	}
}

 	
function ff_event(id){
	if(confirm("您确定通过 ["+provider_name.innerText+"] 提供的项目吗？")){
		 $.ajax({
             type : "POST",
             url : '../rest/comfire_review',
             //async:true,
             data : {
                 id:id
             },
             dataType : "json",
             success : function(data) {
                 if(data.status==false){
                	 alert(data.msg, {icon: 5,time:1500});
				}else{
			         alert(data.msg, {icon: 1,time:1500});
			         //执行重载
                      //location.reload([false])
						realod(); 
			     }
                 }
          });
	}
}
</script>
<script>
	function cencle_reject(){ 
		 $("#reject").hide();
	}
	var reject_reason;
	function add_rejectreason(){
		reject_reason=$("#rejectSelect").find("option:selected").text();
		$("#reject_reason").val(reject_reason); 
		
	}
    function reject_event(id){
    	/* $("#reject").show(); */
    layer.open({
	  type: 1,
	  title:'拒绝理由',
	  skin: 'layui-layer-rim', //加上边框
	  area: ['320', '450'], //宽高
	  content: $('#reject')
	  })
    }
    function due_reject(){
    id=getUrlParam("id");
   	reject_reason=$("#reject_reason").val();
   if(!(/\S/.test(reject_reason))){
		alert("拒绝理由不能为空");  
		return false;
		}
    var data = {"reject_reason":reject_reason,"id":id};
		 $.ajax({
             type : "POST",
             url : '../rest/reject_pass',
             //async:true,
             data : {
                 s_form_data : JSON.stringify(data)
             },
             dataType : "json",
             success : function(data) {
                 if(data.status==false){
                	 alert(data.msg, {icon: 5,time:1000});
				}else{ 
			         alert(data.msg, {icon: 1,time:1000});
			         //执行重载
                      //location.reload([false]) 
						realod();
			     }
                 }
          });
	}
</script>
</html>
